package com.chencs.biz.product.service;

import com.chencs.vo.biz.product.FavoritesModel;
import com.chencs.webmvc.rest.RestFullTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by fangzehua on 2017/6/30.
 */
@Service
public class ProductService {

    private static final Logger logger = LoggerFactory.getLogger(ProductService.class.getName());

    @Autowired
    RestFullTemplate restTemplate;
    /**标志远程服务url**/
    private static final String URLPATH = "service-common/favorites/";

    public String getList() throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "getFavoriteList", String.class,"");
        logger.info("productService getFavoriteList zuulGateWay result {}", ret);
        return ret;
    }



    public String clear_pro() throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "clear_pro", String.class,"3");
        logger.info("productService syncFavorites zuulGateWay result {}", ret);
        return ret;
    }

    public String syncFavorites() throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "syncFavorites", String.class,"");
        logger.info("productService syncFavorites zuulGateWay result {}", ret);
        return ret;
    }



    public String findFavoritesModelByCode(String code) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "findFavoritesModelByCode", String.class,code);
        logger.info("productService findFavoritesModelByCode zuulGateWay result {}", ret);
        return ret;
    }


    public String updateFavoritesByModel(FavoritesModel model) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "updateFavoritesByModel", String.class,model);
        logger.info("productService updateFavoritesByModel zuulGateWay result {}", ret);
        return ret;
    }

    public String syncProductByFavorites(String code) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "syncFavoritesProduct", String.class,code);
        logger.info("productService syncProductByFavorites zuulGateWay result {}", ret);
        return ret;
    }


    public String getProduct() throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "getProduct", String.class,"");
        logger.info("productService getProduct zuulGateWay result {}", ret);
        return ret;
    }



}
